﻿$(document).ready(function () {
    //alert("dfghdf");
    //$('.numbersonly').ForceNumericOnly();

    $('#StartDate').datepicker({
        dateFormat: "dd/mm/yy"
    });

    $('#EndDate').datepicker({
        dateFormat: "dd/mm/yy"
    });
    
 
    
    //------------------------------------------------------------
    
    $('#StartScheduled').datepicker({
        dateFormat: "dd/mm/yy"
    });

    $('#EndScheduled').datepicker({
        dateFormat: "dd/mm/yy"
    });

    $('#TimeApproved').datepicker({
        dateFormat: "dd/mm/yy"
    });

    $('#calendarStartDate').bind("click", function () {
        $('#StartDate').focus();
    });

    $('#calendarEndDate').bind("click", function () {
        $('#EndDate').focus();
    });

    $('#calendarStartScheduled').bind("click", function () {
        $('#StartScheduled').focus();
    });

    $('#calendarEndScheduled').bind("click", function () {
        $('#EndScheduled').focus();
    });

    $('#calendarTimeApproved').bind("click", function () {
        $('#TimeApproved').focus();
    });

    $('#ui-datepicker-div').hide();
});

jQuery.fn.ForceNumericOnly =
    function () {
        return this.each(function () {
            $(this).keydown(function (e) {
                var key = e.charCode || e.keyCode || 0;
                // allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
                return (
                    key == 13 || //enter key
                    key == 8 ||
                    key == 9 ||
                    key == 46 ||
                    (key >= 37 && key <= 40) ||
                    (key >= 48 && key <= 57) ||
                    (key >= 96 && key <= 105));
            });
        });

    };